
!async function () {
    console.log('service_worker开始执行')
    try {
        const backgroundUrl = chrome.runtime.getURL('plugin/background.html')
        const tabs = await chrome.tabs.query({});
        if (!tabs.find(tab => tab.url === backgroundUrl)) {
            // 打开background.html
            await chrome.windows.create(
                {
                    state: 'minimized',
                    type: 'popup',
                    url: backgroundUrl,
                    focused: false,
                },
            );
        }
    } catch (error) {
        console.error(error)
    }
}()
// top: stop后，service_worker定义的全局变量值会丢失